using Microsoft.AspNetCore.Http.Features;

namespace Ke.Paraleet.Hosts.Extensions;

public static class WebOptimizerExtensions
{
    /// <summary>
    /// 启动后自动打开浏览器
    /// </summary>
    /// <param name="app"></param>
    public static void AddWebOptimizer(this IServiceCollection? serv)
    {
        serv.AddWebOptimizer(pipeline =>
        {
            pipeline.AddCssBundle("/css/bundle",
            [
                "lib/bootstrap/dist/css/bootstrap.min.css",
                "lib/bootstrap-icons/bootstrap-icons.min.css",
                "lib/toastr/v2.1.3/toastr.min.css",
                "css/site.css"
            ]);
            pipeline.AddJavaScriptBundle("/js/bundle",
            [
                "lib/jquery/dist/jquery.min.js",
                "lib/bootstrap/dist/js/bootstrap.bundle.min.js",
                "lib/microsoft-signalr/6.0.1/signalr.js",
                "lib/toastr/v2.1.3/toastr.min.js",
                "js/site.js"
            ]);
        }, option =>
        {
            option.EnableCaching = false;
            option.EnableMemoryCache = false;
            option.EnableDiskCache = false;
            option.CacheDirectory = "/temp/weboptimizercache";
            option.EnableTagHelperBundling = true;
            //option.CdnUrl = "https://my-cdn.com/";
            option.AllowEmptyBundle = false;
            option.HttpsCompression = HttpsCompressionMode.Compress;
        });
    }
}